from django.core.management.base import BaseCommand
from django.conf import settings
from django.utils import timezone
import logging
general_log = logging.getLogger('general_log')
#from helpers.case.jb_admin.admin_user import UserPage,UserFields,Group,PermitModel

from quality.models import DepartMent
class Command(BaseCommand):
    """
    """
    def handle(self, *args, **options):
        inst,_ = DepartMent.objects.get_or_create( id=1)
        inst.name='总经半'
        inst.save()
        inst,_ = DepartMent.objects.get_or_create( id=2)
        inst.name='生产部门'
        inst.parent_id=1
        inst.save()
        inst,_ = DepartMent.objects.get_or_create( id=3)
        inst.name='技术部门'
        inst.parent_id=1
        inst.save()
        
        inst,_ = DepartMent.objects.get_or_create( id=4)
        inst.name='销售部门'
        inst.parent_id=1
        inst.save()
        inst,_ = DepartMent.objects.get_or_create( id=5)
        inst.name='客服部门'
        inst.parent_id=1
        inst.save()
        
        
        inst,_ = DepartMent.objects.get_or_create( id=1000)
        inst.name='质量部门'
        inst.parent_id=1
        inst.save()
        
        #group , _ = Group.objects.get_or_create( id =1 )
        #group.name = '高级代理人'
        #group.save()
        #md , _ = PermitModel.objects.get_or_create(group=group)
        #permits =['GamePlayer','GamePlayer_desp','Recharge','-agent_constraint','AgentUser.edit','AgentRecharge.edit','StoreRecord','AgentActionRecord']
        #md.names= ';'.join(permits)
        #md.save()
        
        #group_sub , _ = Group.objects.get_or_create( id =1000 )
        #group_sub.name = '普通代理人'
        #group_sub.save()
        #md , _ = PermitModel.objects.get_or_create(group=group_sub)
        #permits =['GamePlayer','GamePlayer_desp','Recharge','-agent_constraint','AgentActionRecord']
        #md.names= ';'.join(permits)
        #md.save()
        
        #group_sub , _ = Group.objects.get_or_create( id =999 )
        #group_sub.name = '总代理人'
        #group_sub.save()
        #md , _ = PermitModel.objects.get_or_create(group=group_sub)
        #permits =['GamePlayer','GamePlayer_desp','Recharge','-agent_constraint','AgentUser.edit','AgentRecharge.edit','StoreRecord','AgentActionRecord']
        #md.names= ';'.join(permits)
        #md.save()

